package com.ruoyi.news.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SerialNo;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.news.domain.XcxGoodsOrder;
import com.ruoyi.news.mapper.XcxGoodsOrderMapper;
import com.ruoyi.news.service.IXcxGoodsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 小程序-商城订单Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-24
 */
@Service
public class XcxGoodsOrderServiceImpl implements IXcxGoodsOrderService
{
    @Autowired
    private XcxGoodsOrderMapper xcxGoodsOrderMapper;

    /**
     * 查询小程序-商城订单
     * 
     * @param id 小程序-商城订单主键
     * @return 小程序-商城订单
     */
    @Override
    public XcxGoodsOrder selectXcxGoodsOrderById(String id)
    {
        return xcxGoodsOrderMapper.selectXcxGoodsOrderById(id);
    }

    /**
     * 查询小程序-商城订单列表
     * 
     * @param xcxGoodsOrder 小程序-商城订单
     * @return 小程序-商城订单
     */
    @Override
    public List<XcxGoodsOrder> selectXcxGoodsOrderList(XcxGoodsOrder xcxGoodsOrder)
    {
        return xcxGoodsOrderMapper.selectXcxGoodsOrderList(xcxGoodsOrder);
    }

    /**
     * 新增小程序-商城订单
     * 
     * @param xcxGoodsOrder 小程序-商城订单
     * @return 结果
     */
    @Override
    public XcxGoodsOrder insertXcxGoodsOrder(XcxGoodsOrder xcxGoodsOrder)
    {
        String orderId = SerialNo.generateOrderNumber();
        xcxGoodsOrder.setCreateTime(DateUtils.getNowDate());
        xcxGoodsOrder.setUpdateTime(DateUtils.getNowDate());

        xcxGoodsOrder.setOrderId(orderId);
        xcxGoodsOrder.setId(IdUtils.fastSimpleUUID());

        int flag = xcxGoodsOrderMapper.insertXcxGoodsOrder(xcxGoodsOrder);
        if(flag > 0){
            return xcxGoodsOrder;
        }
        return null;
    }

    /**
     * 修改小程序-商城订单
     * 
     * @param xcxGoodsOrder 小程序-商城订单
     * @return 结果
     */
    @Override
    public int updateXcxGoodsOrder(XcxGoodsOrder xcxGoodsOrder)
    {
        xcxGoodsOrder.setUpdateTime(DateUtils.getNowDate());
        return xcxGoodsOrderMapper.updateXcxGoodsOrder(xcxGoodsOrder);
    }

    /**
     * 批量删除小程序-商城订单
     * 
     * @param ids 需要删除的小程序-商城订单主键
     * @return 结果
     */
    @Override
    public int deleteXcxGoodsOrderByIds(String[] ids)
    {
        return xcxGoodsOrderMapper.deleteXcxGoodsOrderByIds(ids);
    }

    /**
     * 删除小程序-商城订单信息
     * 
     * @param id 小程序-商城订单主键
     * @return 结果
     */
    @Override
    public int deleteXcxGoodsOrderById(String id)
    {
        return xcxGoodsOrderMapper.deleteXcxGoodsOrderById(id);
    }
}
